package cn.wolfcode.p2p.mgrsite.controller;

import cn.wolfcode.p2p.base.excetion.DisplayableExcetion;
import cn.wolfcode.p2p.base.query.QueryObjext;
import cn.wolfcode.p2p.base.service.IRealAuthService;
import cn.wolfcode.p2p.base.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

//后台实名认证
@Controller
public class RealAuthController {

    @Autowired
    private IRealAuthService realAuthService;

    @RequestMapping("/realAuth")
    public String realAuth(Model model, @ModelAttribute("qo")QueryObjext qo) {
        model.addAttribute("pageInfo",realAuthService.queryPage(qo));
        return "/realAuth/list";
    }

    //审核按钮
    @RequestMapping("/realAuth_audit")
    @ResponseBody
    public AjaxResult realAuthAudit(Long id,Integer state,String remark){
        AjaxResult result = null;
        try {
            realAuthService.edit(id,state,remark);
            result = new AjaxResult();
        } catch (DisplayableExcetion e) {
            e.printStackTrace();
            result = new AjaxResult(false, e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            result = new AjaxResult(false,"系统出错,请联系管理员");
        }
        return result;
    }





}
